package com.yzd.learnjava.generics;

import com.yzd.learnjava.polymorphism.RandomShapeGenerator;
import com.yzd.learnjava.util.BasicGenerator;
import com.yzd.learnjava.util.Generator;
import com.yzd.learnjava.util.Print;

public class PrimitiveGenericTest {
	public static void main(String[] args) {
		String[] strings = FArray.fill(new String[7], new BasicGenerator<String>(String.class));
		for(String str : strings) {
			Print.print(str);
		}
		
		Integer[] integers = FArray.fill(new Integer[7], new BasicGenerator<Integer>(Integer.class));
		for(int i : integers) {
			Print.print(i);
		}
		
		//int[] integers = FArray.fill(new Integer[7], new BasicGenerator<Integer>(Integer.class));
	}
}

class FArray{
	public static <T> T[] fill(T[] a, Generator<T> gen) {
		for(int i = 0 ; i < a.length; i++) {
			a[i] = gen.next();
		}
		return a ;
	}
}
